import Vue from 'vue'
import VueRouter from 'vue-router'
import Common from '../pages/fore/Common.vue'
import Login from '../pages/fore/Login.vue'
import Register from '../pages/fore/Register.vue'
import Error from '../pages/fore/Error.vue'
// import ModifyPwd from '../components/fore/user/ModifyPwd.vue'
import Home from '../pages/fore/home/Home.vue'
import Stock from '../pages/fore/stock/Stock.vue'
import IndividualStock from '../pages/fore/stock/IndividualStock.vue'
import List from '../pages/fore/stock/List.vue'
import Select from '../pages/fore/stock/Select.vue'
import Market from '../pages/fore/market/Market.vue'
import HSIndex from '../pages/fore/market/HSIndex.vue'
import HSMarket from '../pages/fore/market/HSMarket.vue'
import Plate from '../pages/fore/plate/Plate.vue'

import Disease from '../pages/fore/echarts/Disease.vue'
import K from '../pages/fore/echarts/K.vue'
import Test from '../pages/test/Test.vue'

import User from '../pages/fore/user/User.vue'
import MyInfo from '../components/fore/user/MyInfo.vue'
import UserList from '../components/fore/user/UserList.vue'
import MyStock from '../components/fore/user/MyStock.vue'
// import Home1 from '../components/Home1.vue'

Vue.use(VueRouter)

const routes = []

const router = new VueRouter({
  routes: [
    { path: '/', redirect: '/common'},
    {
      path: '/common',
      component: Common,
      redirect: '/home',
      children: [
        { path: '/home', component: Home },
        {
          path: '/stock',
          component: Stock,
          children: [
            // { path:'/stock/0000001', component: IndividualStock }
            // 动态路由匹配
            // { path:'/stock/:stockCode', component: IndividualStock }
            { path:'/stock/:stockID', component: IndividualStock, props:true}
          ]
        },
        { path: '/stock/list', component: List },
        { path: '/stock/select', component: Select },
        { path: '/market', component: Market },
        { path: '/market/:indexCode', component: HSIndex, props:true },
        { path: '/hsmarket/:indexType', component: HSMarket, props:true },
        { path: '/plate/:plateType', component: Plate, props: true },
        // 访问个人中心，需要是已登录状态，即携带token
        {
          path: '/user',
          component: User,
          redirect: '/myinfo',
          children: [
            // { path:'/stock/0000001', component: IndividualStock }
            // 动态路由匹配
            // { path:'/stock/:stockCode', component: IndividualStock }
            { path:'/myinfo', component: MyInfo,meta: { requireAuth: true}},
            { path:'/admin/user', component: UserList,meta: { requireAuth: true ,roles:['admin']} },
            { path:'/mystock', component: MyStock,meta: { requireAuth: true}}
          ],
          meta: { requireAuth: true }
        },
        { path: '/disease', component: Disease },
        { path: '/k', component: K },
        { path: '/test', component: Test }
      ]
    },
    {path:'/login',component:Login},
    {path:'/error',component:Error},
    {path:'/user/:userType',component:Register, props:true},
    // {path:'/modifyPwd',component:ModifyPwd}
  ]
})

export default router
